package 笔试题.美团;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class 小美记数字 {
    static class Main {
        public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            String s = sc.nextLine();
            String[] s1 = s.split(" ");
            int numCount = Integer.parseInt(s1[0]);
            int askCount = Integer.parseInt(s1[1]);
            String s2 = sc.nextLine();
            String[] s3 = s2.split(" ");
            int[] number = new int[numCount];
            for (int i = 0; i < number.length; i++) {
                number[i] = Integer.parseInt(s3[i]);
            }
            int i = 0;
            int[] askNum = new int[askCount];
            while (i < askCount) {
                String si = sc.nextLine();
                askNum[i++] = Integer.parseInt(si);
            }
            List<String> res = new ArrayList<>();
            for (int k = 0; k < askNum.length; k++) {
                res.add(search(askNum[k], number));
            }
            for (String string : res) {
                System.out.println(string);
            }
        }

        public static String search(int num, int[] number) {
            int start = 0, end = number.length - 1;
            int count = 0;
            while (start <= end) {
                if (number[start] != num) {
                    start++;
                } else {
                    count++;
                }
                if (number[end] != num) {
                    end--;
                } else {
                    count++;
                }
                if (count == 2) break;
            }
            if (start > end) return 0 + " " + 0;
            return start + " " + end;
        }
    }
}
